import 'package:flutter/material.dart';
import 'model/post.dart';

void main()=> runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text("book author"),elevation: 2,),
        body: Home(),
        backgroundColor: Colors.grey[100],
      ),
      theme: ThemeData(
        primarySwatch: Colors.green
      ),
    );
  }
}

class Home extends StatelessWidget {

  Widget _listItemBuilder(BuildContext context,int index){
    return Container(
      color: Colors.grey[200],
      padding: EdgeInsets.all(2.0),
      child: Column(
        children: <Widget>[
          Image.network(posts[index].imageUrl),
          SizedBox(height: 16.0,),
          Text(posts[index].title,style: Theme.of(context).textTheme.title,),
          Text(posts[index].author,style: Theme.of(context).textTheme.subtitle,),
          SizedBox(height: 16.0,),
        ],
      )
    );
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return ListView.builder(itemCount: posts.length,itemBuilder: _listItemBuilder);
  }
}


class Hello extends StatefulWidget {
  @override
  _HelloState createState() {
    return _HelloState();
  }
}

class _HelloState extends State<Hello> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Center(
      child: Text('hello',textDirection: TextDirection.ltr,
        textAlign: TextAlign.left,
        style: TextStyle(
          fontSize: 24.0,
          decoration:TextDecoration.lineThrough,
        ),),
    );
  }
}






